# coding: utf-8
from . import db, BaseModel

from .psy_consultant import PsyConsultant




class Article(db.Model):
    __tablename__ = 'article'

    auto_id = db.Column(db.BigInteger, primary_key=True, info='自增id')
    article_id = db.Column(db.BigInteger, info='文章id')
    title = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='文章标题')
    psy_id = db.Column(db.ForeignKey('psy_consultant.psy_id', ondelete='RESTRICT', onupdate='RESTRICT'), index=True, info='作者id')
    publish_time = db.Column(db.DateTime)
    content = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='文章内容')
    is_delete = db.Column(db.Integer, server_default=db.FetchedValue(), info='是否已删除')
    create_time = db.Column(db.DateTime)
    update_time = db.Column(db.DateTime)

    psy = db.relationship('PsyConsultant', primaryjoin='Article.psy_id == PsyConsultant.psy_id', backref='articles')
